﻿using Blazored.LocalStorage;
using Swimj.RazorLib.Caches;

namespace Client.BlazorWasmApp.Caches;

public class LocalSecureCache : ISecureCache
{
    public Task RemoveAsync(string key)
    {
        Preferences.Remove(key);
        return Task.CompletedTask;
    }

    public Task<string> GetAsync(string key)
    {
        var value = Preferences.Get(key, string.Empty);

        return Task.FromResult(value);
    }

    public Task SetAsync(string key, string value)
    {
        Preferences.Set(key, value);

        return Task.CompletedTask;
    }
}